(function($){
	$.fn.slider = function(options){

		var defaults = {
			 bigPitrue    : $('.big_pitrue'),
			 bigPitrueLi  : $('.big_pitrue').find('li'),
			 bigPitrueImg : $('.big_pitrue').find('li').find('img'),
			 sliderBtn    : $('.slider_btn')
		};

		var opts = $.extend({}, defaults, options)
		var iNow = 0;
		var timer = null;
		var j =true;

		opts.bigPitrue.width(opts.bigPitrueLi.width()*opts.bigPitrueLi.length);
		$(this).height(opts.bigPitrueImg.height());
		opts.bigPitrue.height(opts.bigPitrueImg.height());

		opts.bigPitrueImg.each(function(){

			opts.sliderBtn.append('<li></li>')
		});

		var sliderBtnLi = opts.sliderBtn.find('li');
		sliderBtnLi.eq(0).addClass('active');

		sliderBtnLi.live('click',function(){
			iNow = $(this).index();
			outMove();
		});

		opts.sliderBtn.hover(function(){
			clearInterval(timer);
		},function(){
			outTimer ();
		});

		function outMove ()
		{
			sliderBtnLi.removeClass();
			sliderBtnLi.eq(iNow).addClass('active');
			opts.bigPitrue.animate({left:-opts.bigPitrueLi.width()*iNow},500);
		};

		outTimer ();

		function outTimer ()
		{
			timer = setInterval(function(){
				if(j)
				{
					iNow++;
					if(iNow>opts.bigPitrueLi.length-2)
					{
						j = false;
					}

				}else
				{
					iNow--;
					if(iNow<=0)
					{
						j = true;
					}
				}

				outMove ();
			},3000);
		};

	};

})(jQuery);

(function($){
	$.fn.scrollMove = function(options)
	{
		var defaults = {
			thisUl : $(this).find('ul'),
			move   :'start',
			autoScroll: true
		}
		var opts = $.extend({},defaults, options);

		if(opts.move =='scroll')
		{
			opts.thisUl.html(opts.thisUl.html()+opts.thisUl.html());
		}

		var thisLi = opts.thisUl.find('li');
		var iNow = 0;
		var l = 2;
		var j = true;
		var timer = null;
		var b =true;

		opts.thisUl.width(thisLi.width()*thisLi.length);

		var rightBtn = $(this).find('.icon-chevron-right');
		var leftBtn = $(this).find('.icon-chevron-left');


		switch(opts.move)
		{
			case 'scroll':
				rightBtn.mouseover(function(){
					j = false;
				});

				leftBtn.mouseover(function(){
					j = true;
				});

				thisLi.hover(function(){
					clearInterval(timer);
				},function(){
					outTimer();
				});
				outTimer();
				break;
			case 'start':

				$(this).hover(function(){
					clearInterval(timer);
				},function(){
					if(opts.autoScroll)
					{
						startMove ();
					}
				});

				rightBtn.click(function(){
					j  = false;
					if(iNow>=0)
					{
						iNow = -(thisLi.length-3);
					}
					iNow+=1;
					anima ();
				});

				leftBtn.click(function(){
					j = true;
					iNow-=1;
					if(iNow<=-(thisLi.length-3))
					{
						iNow = 0;
					}
					anima ();
				});

				if(opts.autoScroll)
				{
					startMove ();
				}
				break;
		}

		function outTimer()
		{
			timer = setInterval(function(){
				if(j)
				{
					if(l<=-opts.thisUl.width()/2)
					{
						l = 0;
					}
					l-=2;
				}else
				{
					if(l>=0)
					{
						l = -opts.thisUl.width()/2;
					}
					l+=2;
				}
				opts.thisUl.css({left:l})
			},25);

		};

		function startMove ()
		{
			clearInterval(timer);
			timer = setInterval(function(){
				if(j)
				{
					iNow-=1;
					if(iNow<=-(thisLi.length-4))
					{
						j = false;
					}
				}else
				{
					
					iNow+=1;
					if(iNow>=0)
					{
						j = true;
					}
				}
				anima ();
			},2000)
		}

		function anima ()
		{
			opts.thisUl.animate({left:iNow*thisLi.width()},500);
		};
	};
})(jQuery);